package com.dayvisit;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class DayVisitReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
    private final IntWritable valueOutDayVisit = new IntWritable();

    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {

        int nDayVisit = 0;
        for (IntWritable item : values) {
            nDayVisit += item.get();
        }
        valueOutDayVisit.set(nDayVisit);
        context.write(key, valueOutDayVisit);
    }
}
